package com.qumap.display;

import com.google.gwt.activity.shared.ActivityManager;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.place.shared.PlaceHistoryHandler;
import com.google.gwt.user.client.ui.*;
import com.qumap.display.mvp.DisplayActivityMapper;
import com.qumap.display.mvp.DisplayHistoryMapper;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 05.05.11
 * Time: 13:50
 * To change this template use File | Settings | File Templates.
 */
public class Display {

	private Place default_place = new MapViewPlace();
	private SimplePanel panel = new SimplePanel();

	public void onModuleLoad()  {

		EventBus event_bus = new SimpleEventBus();
		PlaceController controller = new PlaceController(event_bus);

		MapView view = new MapView();
		view.init();

		ActivityMapper activity_map = new DisplayActivityMapper(view);
		ActivityManager manager = new ActivityManager(activity_map, event_bus);

		manager.setDisplay(panel);

		DisplayHistoryMapper history_mapper = GWT.create(DisplayHistoryMapper.class);
		PlaceHistoryHandler history_handler = new PlaceHistoryHandler(history_mapper);
		history_handler.register(controller, event_bus, default_place);

        history_handler.handleCurrentHistory();
	}

    public Widget getRootWidget() {
        return panel;
    }
}
